package com.twu.biblioteca.app.movie;

import com.twu.biblioteca.app.book.CheckoutDetails;
import com.twu.biblioteca.app.book.CheckoutStatus;
import com.twu.biblioteca.app.Item;

public class Movie extends Item  implements Comparable<Movie>{
    private String name;
    private int year;
    private String director;
    private MovieRating movieRating;

    public Movie(String name, int year, String director, MovieRating movieRating) {
        super(name);
        this.name = name;
        this.year = year;
        this.director = director;
        this.movieRating = movieRating;
    }

    public Movie(String name, int year, String director, MovieRating movieRating, CheckoutDetails checkoutDetails) {
        super(name, checkoutDetails);
        this.name = name;
        this.year = year;
        this.director = director;
        this.movieRating = movieRating;
    }

    public int getYear() {
        return year;
    }

    public String getDirector() {
        return director;
    }

    public MovieRating getMovieRating() {
        return movieRating;
    }

    @Override
    public int compareTo(Movie other){
        int compareTitle = this.name.compareTo(other.name);
        return compareTitle == 0 ? this.director.compareTo(other.director) : compareTitle;
    }

    @Override
    public boolean equals(Object otherObj) {
        if (otherObj == null) {
            return false;
        }
        if (getClass() != otherObj.getClass()) {
            return false;
        }

        Movie otherMovie  = (Movie) otherObj;
        if (this.name == otherMovie.name) {
            return this.director == otherMovie.director;
        }
        return false;
    }

}
